function sourceSearchName(){

    $.ajax({
            url: '/api/video/getqiniuvideolist',
            type: 'POST',
            contentType: "application/x-www-form-urlencoded",
            dataType: 'json',
            data: {name: $('#sourceSearch').val()},
            success: function (data) {
                if (mortise_layout.ValidataResult(data)) {
                    if (data.result) {
                        var html = '';
                        $.each(data.result, function (index, item) {
                            html += getSourceSearchHtml(item);
                        })
                        $('#source_url').html(html);

                    }
                    else {
                        alert('返回数据错误！');
                    }
                }
                else {
                    alert('请求数据失败！');
                }
            }
        }
    );
};

function getSourceSearchHtml(dataObject) {
    var stateHtml = '';
    return  '<option value="'+dataObject+'">'+dataObject+'</option>';
};


function SourceInfo(fid, fSourcename, fSourceurl,fShow) {



    var html = ' <form id="sourceform" class="form-horizontal" method="post"' +
        'enctype="multipart/form-data">' +
        '<div             class="form-horizontal">' +
        '<div class="box-body" style="min-width: 480px;">' +
        ' <input type="hidden" name="source_fid" id="source_fid" value="' + fid
        + '">' +
        ' ' +
        ' <div class="form-group">' +
        ' <label  class="col-sm-3 control-label">来源名称</label>' +
        ' <div class="col-sm-4">' +
        '<select class="form-control" id="source_name" name="source_name">'
        + '<option value="本地">本地</option>'
        + '<option value="片花">片花</option>'
        + '</select>' +
        ' </div>' +
        '  </div>' +
        '<div class="form-group">' +
        '<label  class="col-sm-3 control-label">' +
        '   来源搜索</label>' +
        '   <div class="col-sm-4">' +
        ' <input type="text" class="form-control" name="sourceSearch" id="sourceSearch" placeholder="关键字" >' +
        '  </div>' +
        '   <div class="col-sm-3">' +
        '<input type="button"  class="btn btn-block " value="查询" onclick ="sourceSearchName()" />' +
        '  </div>' +
        '   </div>' +
        ' <div class="form-group">' +
        ' <label  class="col-sm-3 control-label">电影列表</label>' +
        ' <div class="col-sm-7">' +
        '<select class="form-control" id="source_url" name="source_url" >'
        + '<option value="'+fSourceurl+'">'+fSourceurl+'</option>'
        + '</select>' +
        ' </div>' +
        '  </div>' +

        ' <div class="form-group">' +
        ' <label  class="col-sm-3 control-label">状态</label>' +
        ' <div class="col-sm-4">' +
        '<select class="form-control" id="source_show" name="source_show" >'
        + '<option value="0">显示</option>'
        + '<option value="1">隐藏</option>'
        + '</select>' +
        ' </div>' +
        '  </div>' +

        ' <div class="box-footer">' +
        '</div>' +
        '</div>' +

        '</form>';



    dialog({
        title: '视频来源',
        content: html,
        cancel: true,
        okValue: '确定',

        ok: function () {
            var options = {
                url: '/api/video/updateSource',
                type: 'post',
                success: function (data) {
                    if (data) {
                        if (data.code == 'OperateOk') {
                            dialog({
                                title: '提示',
                                content: '操作成功！',
                                cancel: false,
                                ok: function () {
                                }
                            }).width(320).showModal();
                            LoadfilmSourceList();
                        }
                        else {
                            dialog({
                                title: '提示',
                                content: '操作失败！',
                                cancel: false,
                                ok: function () {
                                }
                            }).width(320).showModal();
                            LoadfilmSourceList();
                        }
                    }
                }
            };
            $("#sourceform").ajaxSubmit(options);
        }
    }).showModal().width(500).height(250)
    $('#source_name').val(fSourcename)
    $('#source_show').val(fShow)
}




function  loadData(fSourcename,fSourceshow) {
    $('#source_name').val(fSourcename);
    $('#source_show').val(fSourceshow);

}



var SourcenameAry=[{id:'本地',name:'本地'},
    {id:'片花',name:'片花'}];
var SourceshowAry=[{id:'0',name:'显示'},
    {id:'1',name:'隐藏'}];
function SourcenameSelect(id) {
    $('#'+id).empty();
    $.each(SourcenameAry, function (e, i) {
        $("#"+id).append('<option value="' + i.id + '">' + i.name + '</option>');
    });
}
function SourceshowSelect(id) {
    $('#'+id).empty();
    $.each(SourceshowAry, function (e, i) {
        $("#"+id).append('<option value="' + i.id + '">' + i.name + '</option>');
    });
}



function SourceAdd(objectid, classtype) {
    var html = ' <form id="sourceform" class="form-horizontal" method="post"' +
        'enctype="multipart/form-data">' +
        '<div             class="form-horizontal">' +
        '<div class="box-body" style="min-width: 480px;">' +
        ' <input type="hidden" name="objectid" id="objectid" value="' + objectid
        + '">' +
        ' <input type="hidden" name="classtype" id="classtype" value="' + classtype
        + '">' +
        ' ' +
        ' <div class="form-group">' +
        ' <label  class="col-sm-3 control-label">来源名称</label>' +
        ' <div class="col-sm-4">' +
        '<select class="form-control" id="source_name" name="source_name">'
        + '<option value="本地">本地</option>'
        + '<option value="片花">片花</option>'
        + '</select>' +
        ' </div>' +
        '  </div>' +
        '<div class="form-group">' +
        '<label  class="col-sm-3 control-label">' +
        '   来源搜索</label>' +
        '   <div class="col-sm-4">' +
        ' <input type="text" class="form-control" name="sourceSearch" id="sourceSearch" placeholder="关键字" >' +
        '  </div>' +
        '   <div class="col-sm-3">' +
        '<input type="button"  class="btn btn-block " value="查询" onclick ="sourceSearchName()" />' +

        '  </div>' +

        '   </div>' +

        ' <div class="form-group">' +
        ' <label  class="col-sm-3 control-label">电影列表</label>' +
        ' <div class="col-sm-7">' +
        '<select class="form-control" id="source_url" name="source_url" >'
        + '</select>' +
        ' </div>' +
        '  </div>' +
        ' <div class="form-group">' +
        ' <label  class="col-sm-3 control-label">状态</label>' +
        ' <div class="col-sm-4">' +
        '<select class="form-control" id="source_show" name="source_show" >'
        + '<option value="0">显示</option>'
        + '<option value="1">隐藏</option>'
        + '</select>' +
        ' </div>' +
        '  </div>' +

        ' <div class="box-footer">' +
        '</div>' +
        '</div>' +

        '</form>';



    dialog({
        title: '视频来源',
        content: html,
        cancel: true,
        okValue: '确定',

        ok: function () {
            var options = {
                url: '/api/video/addSource',
                type: 'post',
                success: function (data) {
                    if (data) {
                        if (data.code == 'OperateOk') {
                            dialog({
                                title: '提示',
                                content: '操作成功！',
                                cancel: false,
                                ok: function () {
                                }
                            }).width(320).showModal();
                            LoadfilmSourceList();
                        }
                        else {
                            dialog({
                                title: '提示',
                                content: '操作失败！',
                                cancel: false,
                                ok: function () {
                                }
                            }).width(320).showModal();
                            LoadfilmSourceList();
                        }
                    }
                }
            };
            $("#sourceform").ajaxSubmit(options);
        }
    }).showModal().width(500).height(250)
};




